<template>
  <!-- 线下活动详情 -->
  <div class="offlinePage">
    <MyHead title="地区资讯"></MyHead>
    <div class="title-box">
      <div class="title">{{ messageInfo.title }}</div>
      <div class="events-time">活动时间：{{ messageInfo.create_time }}</div>
    </div>
    <div class="content-box">
      <div v-html="this.messageInfo.content"></div>
    </div>
    <div class="btn-style flexc">
      <van-button
        round
        type="info"
        color="#F57373"
        v-if="messageInfo.related_id != '0'"
        @click="goJoin"
      >
        立即参与
      </van-button>
    </div>
  </div>
</template>
    
    <script>
export default {
  data() {
    return {
      id: "",
      openid: $.cookie("openid"),
      messageInfo: {},
      q: "", //关联的活动id
    };
  },
  computed: {},
  methods: {
    /*详情*/
    async informationdetail() {
      let res = await this.$ajax.getinformationdetail({
        openid: this.openid,
        id: this.id,
      });
      if (res.code == 1) {
        this.messageInfo = res.data;
        console.log(this.messageInfo, "this.messageInfo");
        if (res.data.related_id != "0") {
          this.q = res.data.related_id;
        }
      } else {
        console.log(res.msg, "res.msg---");
      }
    },
        /*立即参与*/
        async goJoin() {
      let res = await this.$ajax.getActSurveyInfos({
        openid: this.openid,
        q: this.q,
      });
      if (res.data.act_type == "0" && res.data.have_prize == "1") {
        let res = await this.$ajax.getActSignIn({
          q: this.q,
          openid: this.openid,
          type: "do",
        });
        if (res.code == 1) {
          this.$toast.success(res.msg);
        }
      } else {
        this.$router.push({ name: "provincialmap", query: { q: this.q } });
      }
    },
  },
  mounted() {
    this.id = this.$route.query.id;
    this.informationdetail();
  },
};
</script> 
<style lang="scss" scoped>



.offlinePage {
  background-color: #f8f8f8;
  min-height: 100vh;
  height: 100%;
  .title-box {
    line-height: 30px;
    border-bottom: 1px solid #bbbbbb;
    margin: 10px;
    .title {
      color: rgba(16, 16, 16, 1);
      font-size: 20px;
      text-align: left;
      font-family: SourceHanSansSC-regular;
    }
    .events-time {
      color: rgba(153, 153, 153, 1);
      font-size: 14px;
      text-align: left;
      font-family: SourceHanSansSC-regular;
    }
  }
  .content-box {
    margin: 10px;
    color: rgba(16, 16, 16, 1);
    font-size: 14px;
    text-align: left;
    font-family: PingFangSC-regular;
  }
  .btn-style {
    margin-bottom: 20px;
  }
}
</style>